
#!/bin/bash 
CURRENT_DIRECTORY=`pwd`
FONT_DIR=${CURRENT_DIRECTORY}/out/font
FONT_BUILD_DIR=${FONT_DIR}/build
EMBED_RESOURCE_IN=${FONT_DIR}/in
EMBED_RESOURCE_OUT=${FONT_DIR}/out

rm -fr ${FONT_BUILD_DIR}

source `dirname $0`/build_embed_resource.sh

cp ${CURRENT_DIRECTORY}/assets/fonts/DroidSansFallback.ttf ${EMBED_RESOURCE_IN}/font.ttf

${EMBED_RESOURCE} --extern --in_directory ${EMBED_RESOURCE_IN} --out_directory ${EMBED_RESOURCE_OUT}
cp ${EMBED_RESOURCE_DIR}/Resource.h ${EMBED_RESOURCE_OUT}

cat > ${EMBED_RESOURCE_OUT}/CMakeLists.txt <<EOF
cmake_minimum_required (VERSION 3.20.0)
project(luagui-fontdata)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED true)

aux_source_directory(\${CMAKE_CURRENT_SOURCE_DIR} DIR_SRCS)
add_library(\${PROJECT_NAME} \${DIR_SRCS})
EOF

cmake -S ${EMBED_RESOURCE_OUT} -B ${FONT_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release
cmake --build ${FONT_BUILD_DIR}
